package com.charlotte.gupao.study.springbootrabbitmqdemo.provider;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class MyProvider {

    @Autowired
    AmqpTemplate amqpTemplate;

    public void send(){
        // 发送4条消息

        // 发送消息，为direct模式
        amqpTemplate.convertAndSend("","DIRECT_QUEUE_TEST","-------- a direct msg");

        // 发送topic消息
        amqpTemplate.convertAndSend("TOPIC_EXCHANGE","shanghai.djj.teacher","-------- a topic msg : shanghai.djj.teacher");
        amqpTemplate.convertAndSend("TOPIC_EXCHANGE","changsha.djj.student","-------- a topic msg : changsha.djj.student");

        // 发送fanout广播消息
        amqpTemplate.convertAndSend("FANOUT_EXCHANGE","","-------- a fanout msg");

    }

}
